//
//  MqDetailBrandTableViewCell.m
//  Meiqi
//
//  Created by lanou on 16/1/13.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqDetailBrandTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation MqDetailBrandTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubviews];
    }
    return self;
}


- (void)addSubviews
{
    _imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, kScreenWidth / 3, 100)];
    [self.contentView addSubview:_imageV];
    
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 + kScreenWidth / 3 , 10,  2 * kScreenWidth / 3 - 20, 40)];
    _titleLabel.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:_titleLabel];
    
    _starLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 + kScreenWidth / 3, 50, 2 * kScreenWidth / 3 - 20, 20)];
    //_starLabel.backgroundColor = [UIColor yellowColor];
    for (int i = 0; i < 5; i ++) {
       UIImageView *starImage = [[UIImageView alloc] initWithFrame:CGRectMake(0 + 20 * i, 0, 20, 20)];
       starImage.image = [UIImage imageNamed:@"icon_shop_detail_noRate@3x"];
       starImage.tag = 50 + i;
        [_starLabel addSubview:starImage];
    }
    [self.contentView addSubview:_starLabel];
    
    _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 + kScreenWidth / 3, 80, kScreenWidth / 3 - 20, 30)];
    _priceLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:_priceLabel];
}

- (void)setModel:(MqDetailBrandModel *)model
{
    _model = model;
    
    
    self.titleLabel.text = model.name;
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@"bike"]];
    self.priceLabel.text = [NSString stringWithFormat:@"指导价:%@",model.price];
    
    NSInteger num = [model.star integerValue];
        for (int i = 0; i < num; i ++) {
            UIImageView *star = [_starLabel viewWithTag:50 + i];
            star.image = [UIImage imageNamed:@"icon_shop_detail_rate@3x"];
        }
    
   
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
